#!/usr/bin/env bash
# 启用 POSIX 模式并设置严格的错误处理机制
set -o posix errexit -o pipefail

mkdir -p /home/kubernetes/argocd
cd /home/kubernetes/argocd || exit

rm -rf argocd-*

PROXY=https://www.ghproxy.cn
# 使用uname -m获取架构信息
machine=$(uname -m)
# 判断架构信息并设置变量的值
if [ "$machine" = "aarch64" ]; then
   ARCH="arm64"
elif [ "$machine" = "x86_64" ]; then
   ARCH="amd64"
else
    echo "请手动定义你的发行版的架构"
fi
curl -SL -o argocd "${PROXY}"/https://github.com/argoproj/argo-cd/releases/latest/download/argocd-linux-${ARCH}
mv argocd-linux-${ARCH} /usr/local/bin/
chmod +x /usr/local/bin/argocd
rm argocd-linux-${ARCH}
